$(function(){

    // 模块配置
    var configPath = 'js/config/';
    var configList = {
        index : "首页模块",
        store:"店铺模块",
        brand:"品牌模块",
        recommend:"推荐模块",
        order:"订单模块",
        buyerorder:"我的订单模块",
        member:"会员模块",
        address:"收货地址模块",
        cart:"购物车模块",
        category:"分类列表模块",
        comment:"评论列表模块",
        favorite:"关注模块",
        search:"搜索模块",
        help:"帮助模块"
    };

    // 自动生成接口请求地址
   var hostname = window.location.protocol+'//'+window.location.host,
        port = window.location.port ? ':'+window.location.port : '',
        basename = window.location.pathname.replace('index.html',""),
        basename = basename.split('/');
        basename.splice(-2,1);
    //alert(basename);
    $("#apiUrl").val(hostname + port+ basename.join('/') + 'index.php');

    // 动态加载config文件
    var config = [],lastFile='';
    for (file in configList){lastFile = file;}
    for (file in configList){
        (function(file){
            jQuery.getScript(configPath+file+'.js',function(){
                config = config.concat(eval(file+'Config'));
                if(file == lastFile){
                    $(".submit").AjaxFrom(config);
                }
            })

            $("#modules").append('<option value="'+file+'">'+configList[file]+'</option>');
        })(file);
    }
    $("#modules option").eq(0).attr('selected',true);
});